package com.zxq.frame;

import com.zxq.factory.annotate.DecoderField;
import com.zxq.factory.annotate.EncoderField;
import com.zxq.factory.annotate.Frame;
import com.zxq.factory.annotate.Transcoding;
import com.zxq.factory.enums.EField;
import com.zxq.factory.enums.ETrimMethod;
import com.zxq.frame.jt808.MessageHead;


@Frame(id = 4L,remark = "交通协议")
@Transcoding(coding = 0x7e,transcoding = {0x7d,0x02})
@Transcoding(coding = 0x7d,transcoding = {0x7d,0x01})
public class JT808Frame {

    /**
     * 头标识位
     */
    @EncoderField(field = EField.Byte,len = 1)
    @DecoderField(field = EField.Byte,param = 1)
    byte headFlag = 0x7E;

    /**
     * 消息头
     */
    @EncoderField(sequence = 1,field = EField.Frame)
    @DecoderField(field = EField.Frame)
    MessageHead messageHead;

    /**
     * 消息体
     */
    @EncoderField(sequence = 2,field = EField.Bytes)
    @DecoderField(field = EField.Bytes,method = ETrimMethod.Tail)
    byte[] messageBody;

    /**
     * 校验位
     */
    @EncoderField(sequence = 3,field = EField.Byte)
    @DecoderField(field = EField.Byte,param = 1)
    byte crc;

    /**
     * 尾标识位
     */
    @EncoderField(sequence = 4,field = EField.Byte)
    @DecoderField(field = EField.Byte,param = 1)
    byte tailFlag = 0x7E;

}
